Skip to content

fix(server): environment refusals to an MCP client name its approved access - #40159

Open
juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-37521
Open

juliusmarminge wants to merge 2 commits into
mainfrom
factory/issue-37521

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

When an agent used an MCP client approved below Full access (for example a T3 Connect server in Claude's own MCP settings, approved with Auto) to change projects or environment settings, the refusal said a full-access calling thread was needed. Agents read that as "I'm no longer inside a T3 chat" and stopped. The refusal now names the client and the access it was approved with, and says how to get Full access. Refusals to thread callers keep the existing text.

Fixes #37521

Reproduction on main

Commit aa6fe39 (origin/main). Ran T3CODE_DEV_SEED=0 vp run dev in a fresh worktree, added a scratch git project with t3 project add, and started a Claude Haiku thread with t3 thread start --provider claudeAgent --model claude-haiku-5-5 (a new thread defaults to full access). The agent's call to mcp__t3-code__t3_project_create succeeded. I stopped the dev server and started it again, then used t3 thread send on the same thread for another t3_project_create. It succeeded again through mcp__t3-code__, so the built-in thread credential survives a restart. Next I followed the reporter's actual setup: their claude mcp list shows a second T3 server, t3, on the T3 Connect relay, approved with Auto. T3 does not pass strictMcpConfig to Claude thread sessions (only the capabilities probe does), so Claude loads that server beside t3-code. Against the same dev server, a script registered an MCP client at /oauth/mcp/register, approved it with access auto using a pairing code (/oauth/mcp/decision), exchanged the code with PKCE (scope orchestration:read orchestration:operate), and sent tools/call t3_project_create to /mcp. It got capability_denied with the reporter's exact text: "Changing projects or environment settings needs a live full-access/default calling thread or a full-access client." The failing test on factory/repro-37521 asserts that a refusal to an Auto-approved client names that access and does not mention a calling thread. It fails on main.

Evidence

Register an external MCP client, approve with Auto, exchange the authorization code with PKCE, and call t3_project_create. Restart the real server with the same database and repeat using the same OAuth token. Both sides used fresh isolated Linux server state over loopback HTTP.

Before After
aa6fe390db a290f0834d
Refusal asks for a live full-access/default calling thread. Server transcript Refusal identifies the client's Auto approval and instructs reconnection with Full access. Server transcript

The same result occurred before and after restart. Auto remains correctly refused; this proves the diagnostic correction, not expanded permissions.

Reproduction driver

Not shown:

  • Claude's selection of its separately configured MCP server and subsequent interpretation of the refusal were not exercised; the external OAuth MCP request was driven directly.
  • T3 Connect relay transport was not exercised; requests used the real server's loopback HTTP endpoint.
  • The built-in full-access thread credential and successful project creation after restarting a Claude thread were not reverified.
  • Recovery by reconnecting with Full access was not executed; the head's recovery guidance was observed directly.

Tests

  • CI on a290f08: all 8 required checks passed (Build and Typecheck, Lint, Test, Test Server 1-8)
  • vp test run src/mcp/McpToolAccess.test.ts -t "names that access" without the fix: 1 failed (the repro test)
  • vp test run src/mcp/McpToolAccess.test.ts src/mcp/threadAccess.test.ts src/mcp/linkOrigin.test.ts with the fix: 80 passed
  • vp test run src/mcp/McpHttpServer.test.ts: 43 passed
  • vp run check:changed: format, lint, knip, typecheck and tests all passed

Not in this change

  • Claude thread sessions load the user's own MCP servers next to the built-in t3-code server because strictMcpConfig is passed only to the capabilities probe. Changing that would change which tools users get.

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits November 21, 2026 05:00
… its access

Fails on main: the refusal says a full-access calling thread is needed,
though the caller is an MCP client approved with Auto access (#37521).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…access

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 73e6472 · PR result: a290f08 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The access refusal helper now selects its message from caller context. Environment-writing checks pass the caller to the helper. A test verifies that an outside client with approved auto access receives a refusal that names auto rather than the calling thread.

Changes: Caller-specific access refusals

Layer / File(s) Summary
Caller-aware refusal handling
apps/server/src/mcp/McpToolAccess.ts, apps/server/src/mcp/McpToolAccess.test.ts
The helper builds refusal messages based on caller context. Both environment-writing checks pass the caller to the helper. A test checks the refusal message for an outside client with approved auto access.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#25481 — The PR updates refusal messages for clients below Full access, but does not change the access gate described in this issue.

Possibly related PRs

  • pingdotgg/t3code#37952 — Both PRs change refusal messages for project and environment access checks in McpToolAccess; they provide different access guidance.
  • pingdotgg/t3code#15961 — This PR changes the refusal messaging for the access rule introduced by that PR.

Suggested reviewers: maria-rcks, t3dotgg, macroscopeapp

Merge Risk: Minimal · up to a290f

The change makes refusals for MCP clients approved below Full access name their approved access and explain how to get Full access. Thread-caller refusals are unchanged and permissions are not relaxed. No concrete merge risk remains.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Linked Issues check Inconclusive Issue #37521 asks that a Full-access thread keep project and thread tool access after a server restart. If access cannot be restored, the refusal must say so and give a recovery path. The PR does not … Provide the before and after evidence the PR marks as pending, showing a Full-access thread call after restart on the reviewed head. Confirm that the reported failure comes from the Auto-approved client path and not from a lost thread crede…
Passed Passed checks: 3 passed

Check name Status Explanation
Title check Passed The title names the main change: refusals for environment changes sent to an MCP client now name that client's approved access. It follows the conventional commit format, and it matches the raw summar…
Out of Scope Changes check Passed The changes match the PR objective. fullAccessRequired in apps/server/src/mcp/McpToolAccess.ts now builds its refusal from the caller. It separates callers with no client, clients approved below full-…
Description check Passed The description follows the repository template closely. It has a clear problem statement, a precise change explanation, and a scope tied to a linked issue (#37521). Verification is detailed: a before…
Full details: Title check

Explanation

The title names the main change: refusals for environment changes sent to an MCP client now name that client's approved access. It follows the conventional commit format, and it matches the raw summary of the McpToolAccess.ts change and the new test. It is specific enough for a teammate scanning history to understand the primary change.

Full details: Out of Scope Changes check

Explanation

The changes match the PR objective. fullAccessRequired in apps/server/src/mcp/McpToolAccess.ts now builds its refusal from the caller. It separates callers with no client, clients approved below full-access, and full-access clients limited by runtime or interaction mode. writesEnvironment uses it for both the naming-link check and the full-access check. The added test in apps/server/src/mcp/McpToolAccess.test.ts covers the Auto-approved client case. The test asserts that the message names 'auto' and excludes 'calling thread'. No unrelated file is listed in the summary. The base-to-head diff could not be read, so this verdict relies on the PR summary and the head file contents, which were truncated before the end of the file.

Full details: Description check

Explanation

The description follows the repository template closely. It has a clear problem statement, a precise change explanation, and a scope tied to a linked issue (#37521). Verification is detailed: a before/after reproduction on main, a failing-then-passing test, the specific test commands with counts, and CI results. It also lists what was not verified and what is out of scope. The author identifies the agents used, as the template asks. The description is long, and the Scope section does not state explicitly whether the change is a bug fix (it does: it fixes a reported bug). Overall it is mostly complete and substantive.

Full details: Linked Issues check

Explanation

Issue #37521 asks that a Full-access thread keep project and thread tool access after a server restart. If access cannot be restored, the refusal must say so and give a recovery path. The PR does not change restart or access-restoration code. Its reproduction on main shows that the built-in thread credential survives a restart. It attributes the reported refusal to a separate MCP client, the T3 Connect server approved with Auto, which Claude loads beside t3-code. The PR changes only the refusal text for below-Full-access MCP clients in fullAccessRequired (apps/server/src/mcp/McpToolAccess.ts). Refusals to thread callers keep the old text, which still names the calling thread and gives no recovery path. The PR states that which servers Claude loads is out of scope. Under that scope, the reporter's step 4 call can still reach the Auto server and be refused. The 'Evidence' section is marked as being captured and is not present, and the diff against the merge base could not be read, so the code-level base-to-head comparison is unavailable. Whether the reported scenario is fixed, or is a separate cause, is not established.

Resolution

Provide the before and after evidence the PR marks as pending, showing a Full-access thread call after restart on the reviewed head. Confirm that the reported failure comes from the Auto-approved client path and not from a lost thread credential. If the failing path is the Auto client, state that the issue is resolved by the clearer refusal only, or narrow the issue scope. If a thread credential loss is possible, provide evidence for the restart path and its recovery text.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 8087127 and a290f08.

Files selected for processing: 2

  • apps/server/src/mcp/McpToolAccess.test.ts
  • apps/server/src/mcp/McpToolAccess.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Full-access thread loses project/thread tools after the server restarts, and the error blames the thread

1 participant